class Solution(object):
    def search(self, nums, target):
        """
        :type nums: List[int]
        :type target: int
        :rtype: int
        """
        left = 0
        right = len(nums) - 1
        while left <= right:
            middle = left + (right - left) // 2
            if target < nums[middle]:
                right = middle - 1
            elif target > nums[middle]:
                left = middle + 1
            else:
                return middle

        return -1


if __name__ == '__main__':
    nums = [-1, 0, 1, 4, 6, 8, 11, 32]
    target = 1
    solu = Solution()
    print(solu.search(nums=nums,target=target))